package com.gopay.common.cps.dao.autosettle.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.autosettle.AsCustLimitConfigDAO;

import com.gopay.common.domain.autosettle.AsCustLimitConfig;

/**
 * 
 * @author lizheng
 *
 */
@Repository(value="asCustLimitConfigDAO")
public class AsCustLimitConfigDAOImpl extends BaseDAOImpl<AsCustLimitConfig,Serializable> implements AsCustLimitConfigDAO{

    /**
     * 根据客户ID查询
     * @param custId
     * @return
     */
    @Override
    public AsCustLimitConfig findByCustId(String custId){
//        DetachedCriteria criteria = DetachedCriteria.forClass(AsCustLimitConfig.class);
//        criteria.add(Restrictions.eq("custId", custId));

//        List<AsCustLimitConfig> rsList = this.findByCriteria(criteria);

        String hql = " from AsCustLimitConfig t where t.custId = :custId " ;

        HashMap<String, Object> param = new HashMap<>();
        param.put("custId", custId);
        List<AsCustLimitConfig> rsList = findByHql(hql, param);

        return (rsList != null && rsList.size() > 0) ? rsList.get(0) : null;

    }
}
